const express = require('express');
const router = express.Router();
const vote_handler = require('../router_handler/vote');
const expressJoi = require('@escook/express-joi');

const { 
	add_vote_schema,
	cast_vote_schema,
	add_idea_schema,
	agree_idea_schema,
	delete_vote_schema
} = require('../schema/vote');

// 发布投票第一步,插入投票
router.post('/addVote', expressJoi(add_vote_schema), vote_handler.addVote);
// 发布投票第二步,插入选项
router.post('/addOption', vote_handler.addOption);
// 查询投票
router.get('/getVote', vote_handler.getVote);
// 投票
router.post('/castVote', expressJoi(cast_vote_schema), vote_handler.castVote);
// 删除投票
router.post('/deleteVote', expressJoi(delete_vote_schema), vote_handler.deleteVote);

// 发布意见
router.post('/addIdea', expressJoi(add_idea_schema), vote_handler.addIdea);
// 查询意见
router.get('/getIdea', vote_handler.getIdea);
// 赞同该意见
router.post('/agreeIdea', expressJoi(agree_idea_schema), vote_handler.agreeIdea);

module.exports = router;